<?
/*导览页面，按照分类分别列出不同的数据*/
/*调用的时候传递景点的nid即可，获取所有导览的子分类，用来区分?term_nid=xxxxx即可**/
/*输出二位数组参考*/

include_once("base.php");

$_place_term_nid=$_REQUEST['term_nid'];


//通过relation筛选所有的子分类
$_daolan_terms=select_lines_items($table_prefix."term","listorder desc","nid,name,term_banner","term1 = '".$_place_term_nid."' ","");

//print_r2($_daolan_terms);
//echo "_daolan_terms<br/><br/>";


//循环获取子分类内的文章。
//关系表获取所有的nid，
//之后再筛选所有nid的内容
foreach($_daolan_terms as $k=>$v)
{

//relation获取所有文章nid
    $_relation_list=select_lines_items($table_prefix."relation","nid desc","detail_nid","term_nid = '".$v['nid']."' ","");
    $_relation_list_1array=transform_2darray_in_1darray_number_as_key($_relation_list,"detail_nid");

    //print_r2($_relation_list);
    $_relation_list_str=implode("','",$_relation_list_1array);


    $daolan_detail_list[$v['nid']]=select_lines_items($table_prefix."detail","listorder desc,nid desc","name,clickrate,nid,icon","nid in ('".$_relation_list_str."')","");


    #$v['detail']=$daolan_detail_list;

    #$result

}
//print_r2($daolan_detail_list);
//echo "daolan_detail_list<br/><br/>";

//有了分类列表，文章所属列表，开始循环拼装二w数组

for($i=0;$i<count($_daolan_terms);$i++)
{
    $_result[$i]['term_nid']  = $_daolan_terms[$i]['nid'];
    $_result[$i]['term_name']       = $_daolan_terms[$i]['name'];
    $_result[$i]['term_banner']       = $_daolan_terms[$i]['term_banner'];
    $_result[$i]['list']      = $daolan_detail_list[$_daolan_terms[$i]['nid']];
}



$result=$_result;

echo out("success",0,$result);
?>